<script setup lang="ts">
import { request } from './utils/request'
import { useUserStore } from './stores'
import { onMounted } from 'vue'
import type { User } from './types/user'
const userStore = useUserStore()

// 测试,请求拦截器,是否携带token,401的拦截
const getUserInfo = async () => {
  const res = await request('/patient/myUser')
  console.log(res)
}

// 测试,返回数据相关
const login = async () => {
  const res = await request<User>('/login/password', 'post', {
    mobile: '13211112222',
    password: 'abc12345'
  })
  console.log(res.data.mobile)
  userStore.setUser(res.data)
}

onMounted(() => {
  // getUserInfo()
  login()
})
</script>

<template>
  <!-- 验证css变量 -->
  <a href="">12343566</a>
  <van-button
    type="primary"
    @click="
      userStore.setUser({
        token: '1saddsad',
        refreshToken: 'sdfdsaf',
        avatar: 'dsafsd',
        mobile: 'dsadfdasf',
        account: 'adsfdasf',
        id: 'dasffdsaf'
      })
    "
    >发绿的按钮</van-button
  >
</template>

<style scoped>
a {
  color: var(--cp-primary);
}
</style>
